﻿
using Dora.Orm.Core.Domain.Entities;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Dto.SaveDto;
using Dora.Services.AdminUser.Dto.ViewDto;
using Dora.Services.AdminUser.Entities;
using Dora.Tools.Enums;
using Dora.Tools.Utility.Const;
using Dora.Tools.Utility.Models;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Dora.Services.AdminUser.IApplication
{
    /// <summary>
    /// 供应商用户表服务接口
    /// </summary>
    [ServiceBundle("api/" + DoraModuleName.AdminUser + "/{Service}")]
    public interface ISrmUserService : IServiceKey
    {

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "创建")]
        Task<ResultDto<SrmUserEntity>> Create(SrmUserEntity entity);

        /// <summary>
        /// 根据Id获取一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据Id获取一个实体对象")]
        Task<SrmUserEntity> GetById(Guid id);

        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "分页获取数据")]
        Task<PageDataList<SrmUserListDto>> GetPageList(SrmUserQueryDto input);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "修改")]
        Task<ResultDto> Update(SrmUserEntity entity);

        /// <summary>
        /// 根据IdList获取列表
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据IdList获取列表")]
        Task<List<SrmUserEntity>> GetList(List<Guid> idList);

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "获取所有")]
        Task<List<SrmUserEntity>> GetAll();

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "删除")]
        Task<bool> Delete(Guid id);

        [Service(Date = "2019-04-30", Director = "TTTan", Name = "通过用户名密码登录")]
        Task<ResultDto<IdentityUserDto>> Login(string userName, string pwd, string ip, string systemKey);

        /// <summary>
        /// 通过手机号登录
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="ip"></param>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "通过手机号登录")]
        Task<ResultDto<IdentityUserDto>> LoginByMobile(string mobile, string ip, string systemKey);

        [Service(Date = "2019-02-02", Director = "TTTan", Name = "通过用户名获取员工")]
        Task<SrmUserEntity> GetByUserName(string userName);

        [Service(Date = "2019-02-02", Director = "TTTan", Name = "通过用户名获取员工")]
        Task<SrmUserEntity> GetByMobile(string mobile);


        [Service(Date = "2019-02-02", Director = "TTTan", Name = "修改用户密码")]
        Task<ResultDto> UpdatePassword(Guid userId, string oldPassword, string newPassword);

        [Service(Date = "2019-02-14", Director = "TTTan", Name = "通过员工IdList获取带角色的员工列表")]
        Task<List<SrmUserListDto>> GetListWithRoles(List<Guid> idList);

        /// <summary>
        /// 绑定人员角色
        /// </summary>
        /// <param name="list"></param>
        /// <param name="opOrgId">操作供应商的id</param>
        /// <returns></returns>
        [Service(Date = "2019-02-14", Director = "TTTan", Name = "绑定人员角色")]
        Task<int> BindSrmUserRole(List<SrmUserRoleSaveDto> list, int opOrgId);

        [Service(Date = "2019-02-15", Director = "TTTan", Name = "重置用户密码")]
        Task<ResultDto> ResetPassword(Guid userId, string password);

        /// <summary>
        /// 更新员工的缓存权限
        /// </summary>
        /// <param name="employeeId"></param>
        /// <returns></returns>
        [Service(Date = "2019-02-27", Director = "TTTan", Name = "获取用户有权限的所有系统")]
        Task<bool> RefreshRedisToken(Guid userId);

        /// <summary>
        /// 获取使用这些角色的员工列表
        /// </summary>
        /// <param name="roleIdList"></param>
        /// <returns></returns>
        [Service(Date = "2019-02-27", Director = "TTTan", Name = "获取使用这些角色的员工列表")]
        Task<List<Guid>> GetIdListByRoleIdList(List<Guid> roleIdList);


        /// <summary>
        /// 忘记密码之重置密码
        /// </summary>
        /// <param name="mobile">手机号码</param>
        /// <param name="code">验证码</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        [Service(Date = "2019-03-15", Director = "TTTan", Name = "忘记密码之重置密码")]
        Task<ResultDto> ResetPassword4Forget(string mobile, string code, string password);

        /// <summary>
        /// 用户禁用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opId"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-06", Director = "TTTan", Name = "用户禁用")]
        Task<bool> Disable(Guid id, Guid opId, string opName);

        /// <summary>
        /// 用户启用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opId"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-06", Director = "TTTan", Name = "用户启用")]
        Task<bool> Enable(Guid id, Guid opId, string opName);

        /// <summary>
        /// 用户冻结
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opId"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-06", Director = "TTTan", Name = "用户冻结")]
        Task<bool> Frozen(Guid id, Guid opId, string opName);

        /// <summary>
        /// 用户解冻
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opId"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-06", Director = "TTTan", Name = "用户解冻")]
        Task<bool> UnFrozen(Guid id, Guid opId, string opName);

        /// <summary>
        /// 修改用户基本信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-27", Director = "TTTan", Name = "修改用户基本信息")]
        Task<ResultDto> UpdateBaseInfo(SrmUserBaseInfoSaveDto input);

        /// <summary>
        /// 修改用户手机号
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-28", Director = "TTTan", Name = "修改用户手机号")]
        Task<ResultDto> UpdateMobile(SrmUserEntity entity);

        /// <summary>
        /// 修改用户的供应商Id
        /// </summary>
        /// <param name="srmUserId"></param>
        /// <param name="supplierId"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-05", Director = "李龙", Name = "修改用户的供应商Id")]
        Task<ResultDto> UpdateSupplierId(Guid srmUserId, int supplierId);

        /// <summary>
        /// 根据角色编号绑定用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleNO"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-06", Director = "TTTan", Name = "根据角色编号绑定用户角色")]
        Task<int> BindRoleWithRoleNO(Guid userId, string roleNO);

        /// <summary>
        /// 根据角色编号解绑用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleNO"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-06", Director = "TTTan", Name = "根据角色编号解绑用户角色")]
        Task<int> UnBindRoleWithRoleNO(Guid userId, string roleNO);

        /// <summary>
        /// 更新环信Id
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-06", Director = "TTTan", Name = "更新环信Id")]
        Task<ResultDto> UpdateHxUserName(Guid userId, string hxUserName);

        /// <summary>
        /// 获取某个供应商下的所有用户
        /// </summary>
        /// <param name="supplierId">供应商Id</param>
        /// <param name="notInUserId">要排除的用户id</param>
        /// <returns></returns>
        [Service(Date = "2019-06-06", Director = "TTTan", Name = "获取某个供应商下的所有用户")]
        Task<List<SrmUserListDto>> GetListBySupplierIdButOne(int supplierId, Guid notInUserId);
        /// <summary>
        ///  获取某个供应商下的管理员用户
        /// </summary>
        /// <param name="supplierId"></param>
        /// <param name="roleNo"></param>
        /// <returns></returns>
        [Service(Date = "2019-10-17", Director = "gl", Name = " 获取某个供应商下的某个角色用户")]
        Task<List<SrmUserListDto>> GetSrmAdminUserListBySupplierId(int supplierId, string roleNo);
    }
}
